<?php
include '../../public/func.inc.php';

//var_dump($_POST);
if($_FILES['logo']['error'] !=4){
	$logoname = upload('logo','../../home/resource/images/');
	//如果上传头像过大  可以调用缩进放入函数进行缩放
	if($logoname){
		if(suofang('../../home/resource/images/'.$logoname)){
			@unlink('../../home/resource/images/'.$logoname);
		}
	}
	//修改表单隐藏域的logo 用户修改logo使用上传后的logo 用户不修改logo使用表单隐藏的logo
	$_POST['WZ_LOGO'] = $logoname;
}

//var_dump($_POST);


//拼接成原文件的字符串格式  (利用字符串) 再覆盖写到文件中

$str = "<?php\n";
foreach($_POST as $k => $v){
	$str .= "const {$k} = '{$v}';\n";
}
var_dump($str);

if(file_put_contents('../../public/webconfig.php', $str)){
	echo '<script>alert("编辑成功");window.location.href="edit.php";</script>';
}else{
	echo '<script>alert("编辑失败");window.location.href="edit.php";</script>';
}